<template>
  <div>
    <!-- 如果是三张图片 v-if="item.images.length==3"-->
    <div class="multiImg" v-if=" textInfo.images.length>=3">
      <div class="recommend_info">
        <div @click="goDetails" style="cursor: pointer">
          <div class="recommend_info_title">{{textInfo.title}}</div>
          <div class="recommend_info_text" v-html="textInfo.summary"></div>
          <div class="recommend_info_multiWr">
            <img :src="textInfo.images[0]" alt />
            <img :src="textInfo.images[1]" alt />
            <img :src="textInfo.images[2]" alt />
          </div>
        </div>
        <div class="recommend_info_author">
          <div class="author_l">
            <span>
              <i class="el-icon-location-outline" />
              {{textInfo.cityName}}
            </span>
            <span class="middle">
              by
              <img :src="$axios.defaults.baseURL+textInfo.account.defaultAvatar" alt />
              <span class="changeColor">{{textInfo.account.nickname}}</span>
            </span>
            <span>
              <i class="el-icon-view" />
              {{textInfo.watch}}
            </span>
          </div>
          <div class="like">
            {{textInfo.like?textInfo.like:0}}
            赞
          </div>
        </div>
      </div>
    </div>
    <!-- 如果是1-两张图片 -->
    <div class="singleImg" v-if="textInfo.images.length>0&&textInfo.images.length<3">
      <div class="singleImg_info">
        <div class="singleImg_info_img" @click="goDetails" style="cursor: pointer">
          <img :src="textInfo.images[0]" alt />
        </div>
        <div class="left_R">
          <div @click="goDetails" style="cursor: pointer">
            <div class="recommend_info_title">{{textInfo.title}}</div>
            <div class="recommend_info_text" v-html="textInfo.summary"></div>
          </div>

          <div class="recommend_info_author">
            <div class="author_l">
              <span>
                <i class="el-icon-location-outline" />
                {{textInfo.cityName}}
              </span>
              <span class="middle">
                by
                <img :src="$axios.defaults.baseURL+textInfo.account.defaultAvatar" alt />
                <span class="changeColor">{{textInfo.account.nickname}}</span>
              </span>
              <span>
                <i class="el-icon-view" />
                {{textInfo.watch}}
              </span>
            </div>
            <div class="like">
              {{textInfo.like?textInfo.like:0}}
              赞
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 没有图片的情况 -->
    <div class="noImg" v-if=" textInfo.images.length<=0">
      <div class="noImg_info">
        <div @click="goDetails" style="cursor: pointer">
          <div class="recommend_info_title">{{textInfo.title}}</div>
          <div class="recommend_info_text" v-html="textInfo.summary"></div>
        </div>

        <div class="recommend_info_author">
          <div class="author_l">
            <span>
              <i class="el-icon-location-outline" />
              {{textInfo.cityName}}
            </span>
            <span class="middle">
              by
              <img :src="$axios.defaults.baseURL+textInfo.account.defaultAvatar" alt />
              <span class="changeColor">{{textInfo.account.nickname}}</span>
            </span>
            <span>
              <i class="el-icon-view" />
              {{textInfo.watch}}
            </span>
          </div>
          <div class="like">
            {{textInfo.like?textInfo.like:0}}
            赞
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["textInfo"],
  methods: {
    goDetails() {
      this.$router.push({
        path: "/post/details",
        query: { city: this.textInfo.id },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.multiImg {
  .recommend_info {
    padding: 20px 0;
    border-bottom: 1px solid #eee;
    /* margin-bottom: 20px; */
    .recommend_info_title {
      height: 24px;
      font-size: 18px;
      margin-bottom: 15px;

      &:hover {
        color: #ffa500;
      }
    }
    .recommend_info_text {
      font-size: 14px;
      color: #666;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 3;
      -webkit-box-orient: vertical;
      margin-bottom: 15px;
      height: 58px;
    }
    .recommend_info_multiWr {
      display: flex;
      justify-content: space-between;

      height: 150px;
      margin-bottom: 20px;
      img {
        width: 220px;
        height: 150px;
        object-fit: cover;
      }
    }
    .recommend_info_author {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 26px;
      font-size: 12px;
      color: #666;

      .author_l {
        display: flex;
        justify-content: center;
        align-items: center;
        img {
          width: 16px;
          height: 16px;
          border-radius: 100px;
          margin: 5px;
        }
        span {
          margin-right: 10px;
        }
        .middle {
          display: flex;
          align-items: center;
          justify-content: center;
        }
        .changeColor {
          color: orange;
        }
      }
      .like {
        font-size: 20px;
        color: orange;
      }
    }
  }
}
.singleImg {
  .singleImg_info {
    display: flex;
    /*   justify-content: space-between; */
    padding: 20px 0;
    border-bottom: 1px solid #eee;
    .singleImg_info_img {
      width: 220px;
      height: 150px;
      margin-right: 10px;
      img {
        width: 220px;
        height: 150px;
        object-fit: cover;
      }
    }
    .left_R {
      width: 70%;
      .recommend_info_title {
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        height: 24px;
        font-size: 18px;
        margin-bottom: 15px;
        &:hover {
          color: #ffa500;
          cursor: pointer;
        }
      }
      .recommend_info_text {
        font-size: 14px;
        color: #666;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        margin-bottom: 15px;
        height: 58px;
      }
      .recommend_info_author {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 26px;
        font-size: 12px;
        color: #666;
        .author_l {
          display: flex;
          justify-content: center;
          align-items: center;
          img {
            width: 16px;
            height: 16px;
            border-radius: 100px;
            margin: 5px;
          }
          span {
            margin-right: 10px;
          }
          .middle {
            display: flex;
            align-items: center;
            justify-content: center;
          }
          .changeColor {
            color: orange;
          }
        }
        .like {
          font-size: 20px;
          color: orange;
        }
      }
    }
  }
}
.noImg {
  padding: 20px 0;
  border-bottom: 1px solid #eee;
  .noImg_info {
    height: 143px;
    .recommend_info_title {
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
      height: 24px;
      font-size: 18px;
      margin-bottom: 15px;
      &:hover {
        color: #ffa500;
      }
    }
    .recommend_info_text {
      height: 58px;
      margin-bottom: 15px;
      font-size: 14px;
      color: #666;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 3;
      -webkit-box-orient: vertical;
      margin-bottom: 15px;
    }
    .recommend_info_author {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 26px;
      font-size: 12px;
      color: #666;
      .author_l {
        display: flex;
        justify-content: center;
        align-items: center;
        img {
          width: 16px;
          height: 16px;
          border-radius: 100px;
          margin: 5px;
        }
        span {
          margin-right: 10px;
        }
        .middle {
          display: flex;
          align-items: center;
          justify-content: center;
        }
        .changeColor {
          color: orange;
        }
      }
      .like {
        font-size: 20px;
        color: orange;
      }
    }
  }
}
</style>